<?php use_javascript('jquery-1.3.2.min.js') ?>
<?php use_helper ('Form','Javascript','Object') ?>

<?php use_javascript('prototype.js') ?>		
<?php use_javascript('effects.js') ?>		
<?php use_javascript('dragdrop.js') ?>		
<?php use_javascript('popup.js') ?>		
<link href="<?php echo _compute_public_path('popup', 'css', 'css', false);  ?>" rel="stylesheet" type="text/css" />	

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="heading_table">
	<tr>
		<td height="30"><span class="heading">Electricity Tariff List</span></td>
		<td align="right" height="30" valign="bottom">
        <span style="float:right"><?php echo image_tag('icon_addRight.jpg', 'width="2"', 'height="22"')?></span>
        <a class="addNew" id="popup_link_add" href="#">Add New Tariff Rate</a></td>
	</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="datagrid">
             
	  <tr>
		<th width="17%" style="text-align:left;">Title</th>
		<th width="9%" style="text-align:left;">From (unit)</th>
		<th width="7%" style="text-align:left;">To (unit)</th>
		<th width="17%" style="text-align:left;">JCO/OR/Civ Rate (Rs.)</th>
        <th width="15%" style="text-align:left;">Rebate Rate (Rs.)</th>
        <th width="14%" style="text-align:left;">Officer Rate (Rs.)</th>
		<th width="11%" style="text-align:left;">Last Updated</th>
		<th width="10%" style="text-align:left;">Operation</th>
	  </tr>
			  
			 <!-- Populating the List -->
			
		<?php if (count($tarrifs)): ?>
			<?php foreach ($tarrifs as $tarrif): ?>
				<tr>
                <td align="left"><?php echo $tarrif->getTitle(); ?> </td>
				<td align="left"><?php echo $tarrif->getFromUnit(); ?> </td>
				<td align="left"><?php echo $tarrif->getToUnit(); ?></td>
				<td align="center"><?php echo $tarrif->getCivilRate(); ?></td>
                <td align="center"><?php echo $tarrif->getRebateRate(); ?></td>
                <td align="center"><?php echo $tarrif->getOfficerRate(); ?></td>
				<td align="center"><?php echo $tarrif->getUpdatedAt('d-M-Y'); ?></td>
				<td align="right">
				<?php echo link_to('&nbsp;','ElecTarrif/edit?id='.Utility::EncryptQueryString($tarrif->getId()),array('title'=>'Edit', 'class' => 'edit'))?>
				
				<?php echo link_to('&nbsp;','ElecTarrif/delete?id='.Utility::EncryptQueryString($tarrif->getId()), array('confirm'=>'Are you sure you want to Delete this?', 'title'=>'Delete', 'class' => 'delete')); ?>
				</td>
              </tr>
			<?php endforeach ?>
		
			<tr>
				<td class="last">&nbsp;</td>
			</tr>
			
			<?php else:?>
			  
			<tr>
				<td colspan="6" style="background:none; text-align:center;"><?php echo Constant::RECORD_NOT_FOUND; ?></td>
			</tr>
					
			  <?php endif; ?>
            </table>
			
<div id="popup_add" class="popup" style="width:600px" >

<?php echo form_tag('ElecTarrif/add') ?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="padding-left:10px" height="30"><span class="heading">Add New Tariff Rate</span></td>
    <td align="right" style="padding-right:10px"><a class="popup_closebox" href="#"><?php echo image_tag('btn_x.gif', 'border=0'); ?></a></td>
  </tr>
</table>


<table width="100%"  cellpadding="0" cellspacing="0" align="left" border="0" class="form" bgcolor="#eeeeee">
  
 
  <tr>
    <td width="191" align="left" height="30" style="padding-left:10px; padding-top:10px">Title:<span class="error"> *</span></td>
	<td width="409" align="left" height="30" style="padding-left:10px; padding-top:10px"> <?php echo input_tag('title','','size=20') ?></td>
	<script type="text/javascript">
	var title = new LiveValidation('title', { validMessage: "<?php echo Constant::VALIDATION_SUCCESS; ?>"});
	title.add( Validate.Presence,{ failureMessage: "<?php echo Constant::VALIDATION_REQUIRED_FIELD; ?>"});
	</script>
  </tr>
  
  <tr>
    <td width="191" align="left" height="30" style="padding-left:10px; padding-top:10px">From (unit):<span class="error"> *</span></td>
	<td width="409" align="left" height="30" style="padding-left:10px; padding-top:10px"> <?php echo input_tag('from_unit','','size=7') ?></td>
	<script type="text/javascript">
	var from_unit = new LiveValidation('from_unit', { validMessage: "<?php echo Constant::VALIDATION_SUCCESS; ?>"});
	from_unit.add( Validate.Presence,{ failureMessage: "<?php echo Constant::VALIDATION_REQUIRED_FIELD; ?>"});
	from_unit.add( Validate.Format, { pattern: /^[\d\.\/\(\)]*$/,failureMessage: "<?php echo Constant::VALIDATION_INTEGER_FIELD;  ?>"} );
	</script>
  </tr>
  
  <tr>
    <td width="191" align="left" height="30" style="padding-left:10px; padding-top:10px">To (unit):<span class="error"> *</span></td>
	<td width="409" align="left" height="30" style="padding-left:10px; padding-top:10px"> <?php echo input_tag('to_unit','','size=7') ?></td>
	<script type="text/javascript">
	var to_unit = new LiveValidation('to_unit', { validMessage: "<?php echo Constant::VALIDATION_SUCCESS; ?>"});
	to_unit.add( Validate.Presence,{ failureMessage: "<?php echo Constant::VALIDATION_REQUIRED_FIELD; ?>"});
	to_unit.add( Validate.Format, { pattern: /^[\d\.\/\(\)]*$/,failureMessage: "<?php echo Constant::VALIDATION_INTEGER_FIELD;  ?>"} );
	</script>
  </tr>
  
  <tr>
    <td width="191" align="left" height="30" style="padding-left:10px; padding-top:10px">JOC/OR/Civil Rate (Rs.):<span class="error"> *</span></td>
	<td width="409" align="left" height="30" style="padding-left:10px; padding-top:10px"> <?php echo input_tag('civil_rate','','size=7') ?></td>
	<script type="text/javascript">
	var civil_rate = new LiveValidation('civil_rate', { validMessage: "<?php echo Constant::VALIDATION_SUCCESS; ?>"});
	civil_rate.add( Validate.Presence,{ failureMessage: "<?php echo Constant::VALIDATION_REQUIRED_FIELD; ?>"});
	civil_rate.add( Validate.Format, { pattern: /^[\d\.\/\(\)]*$/,failureMessage: "<?php echo Constant::VALIDATION_INTEGER_FIELD;  ?>"} );
	</script>
  </tr>
  
  <tr>
    <td width="191" align="left" height="30" style="padding-left:10px; padding-top:10px">Rebate Rate (Rs.):<span class="error"> *</span></td>
	<td width="409" align="left" height="30" style="padding-left:10px; padding-top:10px"> <?php echo input_tag('rebate_rate','','size=7') ?></td>
	<script type="text/javascript">
	var rebate_rate = new LiveValidation('rebate_rate', { validMessage: "<?php echo Constant::VALIDATION_SUCCESS; ?>"});
	rebate_rate.add( Validate.Presence,{ failureMessage: "<?php echo Constant::VALIDATION_REQUIRED_FIELD; ?>"});
	rebate_rate.add( Validate.Format, { pattern: /^[\d\.\/\(\)]*$/,failureMessage: "<?php echo Constant::VALIDATION_INTEGER_FIELD;  ?>"} );
	</script>
  </tr>
  
  <tr>
    <td width="191" align="left" height="30" style="padding-left:10px; padding-top:10px">Officer Rate (Rs.):<span class="error"> *</span></td>
	<td width="409" align="left" height="30" style="padding-left:10px; padding-top:10px"> <?php echo input_tag('officer_rate','','size=7') ?></td>
	<script type="text/javascript">
	var officer_rate = new LiveValidation('officer_rate', { validMessage: "<?php echo Constant::VALIDATION_SUCCESS; ?>"});
	officer_rate.add( Validate.Presence,{ failureMessage: "<?php echo Constant::VALIDATION_REQUIRED_FIELD; ?>"});
	officer_rate.add( Validate.Format, { pattern: /^[\d\.\/\(\)]*$/,failureMessage: "<?php echo Constant::VALIDATION_INTEGER_FIELD;  ?>"} );
	</script>
  </tr>

  
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  
  <tr>
		<td>&nbsp;</td>
		<td colspan="2">
		<table width="100%" align="left" border="0" class="form">
			<tr>
				<td width="2%"><?php echo submit_tag('', array('class'=>'btn_add', 'style'=>'border:none'))

; ?> </td>
				<td width="98%"><a class="popup_closebox" href="#"><?php echo image_tag('btn_cancel.gif', 'border=0'); ?></a></td>
			</tr>
    	</table>
		</td>
  </tr>
</table>

</div>
<script type="text/javascript">
    //<![CDATA[
    new Popup('popup_add','popup_link_add',{modal:true,duration:1})
    //]]>
  </script>